package com.ruku.controller;

import com.bean.PanDian;
import com.bean.WmsTStore;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruku.service.RuKuService;
import com.ruku.service.Ruku2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Controller
@RequestMapping("rukuu")
public class Ruku2Controller {
    @Autowired
    Ruku2Service ruKu2Service;
    @RequestMapping("selectmingxi.do")
    public String ruKuselect(HttpServletRequest request) {
        return "ruku/rukudanSelect";
    }

    @RequestMapping("selectmingxi2.do")
    public String select(String pageSize, String pageNum,String billID,String custName,String start,String end,HttpServletRequest request) {
        request.getSession().setAttribute("start33", start);
        request.getSession().setAttribute("end33", end);
        request.getSession().setAttribute("custName33", custName);
        request.getSession().setAttribute("billID33", billID);
        //开始分页
        if (pageSize==null||pageSize.equals("")) {
            PageHelper.startPage(1, 5);
            //pageSize & pageNum 放域
            request.getSession().setAttribute("num33", 1);
            request.getSession().setAttribute("size33", 5);
            System.out.println("没值");
        } else {
            PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
            //pageSize & pageNum 放域
            request.getSession().setAttribute("num33", Integer.parseInt(pageNum));
            request.getSession().setAttribute("size33", Integer.parseInt(pageSize));
            System.out.println("有值");
        }
        List<Map<String, Object>> details = ruKu2Service.selectdetails(start,end,custName,billID);
        PageInfo<List<Map<String, Object>>> pageInfo = new PageInfo(details);
        System.out.println("分页为：");
        System.out.println(pageInfo);
        //放域
        request.getSession().setAttribute("pageInfo33", pageInfo);
        return "ruku/rukudanSelect";
    }
}
